import {defineStore} from "pinia";
import {ref} from "vue";
import {getHosDetailAPI, getUserAPI, submitOrderAPI} from "@/api/clientApi.ts";
import {submitOrderInterface} from "@/views/member/interface/interface.ts";

const useClientStore = defineStore("clientStore", () => {
    const userList = ref([])
    const hosDetail = ref({})
    const fetchUserList = async () => {
        const {data} = await getUserAPI()
        userList.value = data
    }
    const fetchHosDetail = async (id: string) => {
        const {data} = await getHosDetailAPI(id)
        hosDetail.value = data
    }

    const submitOrder = async (params: submitOrderInterface) => {
        const {data} = await submitOrderAPI(params)
        return data
    }
    return {
        userList,
        hosDetail,
        fetchUserList,
        fetchHosDetail,
        submitOrder
    }
})

export default useClientStore
